package com.cn.movie.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cn.movie.mapper.YjzyMovieDetailMapper;
import com.cn.movie.pojo.Yjzymoviedetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

@Controller
public class MeController {

    @Autowired
    private YjzyMovieDetailMapper yjzyMovieDetailMapper;

        @RequestMapping(value = "/index",method = {RequestMethod.GET})
        public String index(Model model){
            //条件查询
            QueryWrapper<Yjzymoviedetail> queryWrapper = new QueryWrapper<Yjzymoviedetail>();
            queryWrapper.isNotNull("introduction").ne("img","").last("LIMIT 6");
            List<Yjzymoviedetail> yjzymoviedetails = yjzyMovieDetailMapper.selectList(queryWrapper);
            model.addAttribute("mobile",yjzymoviedetails);
            //精选查询
            queryWrapper.clear();
            queryWrapper.isNotNull("introduction").ne("img","").like("videoMainActors","周星驰").last("LIMIT 6");
            List<Yjzymoviedetail> yjzymoviedetails1=yjzyMovieDetailMapper.selectList(queryWrapper);
            model.addAttribute("jingxuan",yjzymoviedetails1);

            //顶视查询
            queryWrapper.clear();
            queryWrapper.ne("introduction","").ne("img","").like("videoMainActors","刘德华").last("LIMIT 6");
            List<Yjzymoviedetail> yjzymoviedetails2=yjzyMovieDetailMapper.selectList(queryWrapper);
            model.addAttribute("dingshi",yjzymoviedetails2);
            //最高评分
            queryWrapper.clear();
            queryWrapper.ne("introduction","").ne("img","").ge("douBanId",9.5).last("LIMIT 6");
            List<Yjzymoviedetail> yjzymoviedetails3=yjzyMovieDetailMapper.selectList(queryWrapper);
            model.addAttribute("pingfeng",yjzymoviedetails3);

            //最近添加
            queryWrapper.clear();
            queryWrapper.ne("introduction","").ne("img","").like("ReleaseDate","2020").last("LIMIT 6");
            List<Yjzymoviedetail> yjzymoviedetails4=yjzyMovieDetailMapper.selectList(queryWrapper);
            model.addAttribute("zuijin",yjzymoviedetails4);

            return "movie";
        }


}
